//
//  CarLocationViewController.m
//  duoduo
//
//  Created by wanghao on 16/10/28.
//  Copyright © 2016年 LX. All rights reserved.
//

#import "CarLocationViewController.h"
#import "LXMapView.h"
#import "PayOrderVC.h"

@interface CarLocationViewController ()
{
    LXMapView * homeMap_;
    UIView * allView;
}
@end

@implementation CarLocationViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    self.title = @"停车位置";
    [self initMap];
    [self initSomeView];

}

- (void)initMap
{
    LXMapView * map = [[LXMapView alloc]initWithMapFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight-150)];
    [self.view addSubview:map];
    map.index = 2;
    homeMap_ = map;

    allView.alpha = 0;
    UIView * bottomView = [[UIView alloc]initWithFrame:CGRectMake(0, ScreenHeight-150, ScreenWidth, 80)];
    UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(15, 20, ScreenWidth-30, 45)];
    [button setTitle:@"下车锁门" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    button.backgroundColor = LXHexColor(0x5DCA68);
    button.layer.cornerRadius = 6;
    button.layer.masksToBounds = YES;
    [button addTarget:self action:@selector(suomenClick) forControlEvents:UIControlEventTouchUpInside];
    [bottomView addSubview:button];
    [self.view addSubview:bottomView];

}

- (void)suomenClick
{
    [self.view addSubview:allView];

    allView.alpha = 0.9;
}

- (void)initSomeView
{
    allView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    allView.backgroundColor = [UIColor grayColor];
    allView.alpha = 1.0;

    UIView * needView = [[UIView alloc]initWithFrame:CGRectMake(25, 50, ScreenWidth-50, 380)];
    needView.backgroundColor = [UIColor whiteColor];
    needView.layer.cornerRadius = 10;
    needView.layer.masksToBounds = YES;
    needView.alpha= 1.0;
    [allView addSubview:needView];
    //头部view
    UIView * topView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth-50, 50)];
    topView.backgroundColor = LXHexColor(0x5DCA68);
    [needView addSubview:topView];

    //车辆名
    UILabel * carName = [[UILabel alloc]initWithFrame:CGRectMake(15, 15, 200, 20)];
    carName.text = @"银白色宝马525LI";
    carName.textColor = [UIColor whiteColor];
    carName.font = [UIFont systemFontOfSize:15];
    [topView addSubview:carName];

    //中间层view
    UIView * middleView = [[UIView alloc]initWithFrame:CGRectMake(0, 50, ScreenWidth-50, 330)];
    [needView addSubview:middleView];

    //订单name
    UILabel * OrderID = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 60, 20)];
    OrderID.text = @"订单号:";
    OrderID.font = [UIFont systemFontOfSize:14];
    [middleView addSubview:OrderID];
    //订单号
    UILabel * orderlabel = [[UILabel alloc]initWithFrame:CGRectMake(70, 10, 150, 20)];
    orderlabel.text = @"5684684118";
    orderlabel.font = [UIFont systemFontOfSize:14];
    [middleView addSubview:orderlabel];

    //车牌name
    UILabel * carID = [[UILabel alloc]initWithFrame:CGRectMake(10, 35, 60, 20)];
    carID.text = @"车牌号:";
    carID.font = [UIFont systemFontOfSize:14];
    [middleView addSubview:carID];
    //车牌号
    UILabel * carlabel = [[UILabel alloc]initWithFrame:CGRectMake(70, 35, 150, 20)];
    carlabel.text = @"粤B·8A966";
    carlabel.font = [UIFont systemFontOfSize:14];
    [middleView addSubview:carlabel];

    //开始时间
    UILabel * startTimeID = [[UILabel alloc]initWithFrame:CGRectMake(10, 60, 200, 20)];
    startTimeID.text = @"开始时间: 2016-10-01 09:30";
    startTimeID.font = [UIFont systemFontOfSize:14];
    [middleView addSubview:startTimeID];

    //结束时间
    UILabel * endingTimeID = [[UILabel alloc]initWithFrame:CGRectMake(10, 85, 200, 20)];
    endingTimeID.text = @"结束时间: 2016-10-03 15:45";
    endingTimeID.font = [UIFont systemFontOfSize:14];
    [middleView addSubview:endingTimeID];

    //取车位置
    UILabel * fromCarLocationID = [[UILabel alloc]initWithFrame:CGRectMake(10, 105, 250, 40)];
    fromCarLocationID.text = @"取车位置: 广东省深圳市宝安区坪洲地铁站D出口";
    fromCarLocationID.font = [UIFont systemFontOfSize:14];
    fromCarLocationID.numberOfLines = 2;
    [middleView addSubview:fromCarLocationID];

    //停车位置
    UILabel * endCarLocationID = [[UILabel alloc]initWithFrame:CGRectMake(10, 150, 250, 40)];
    endCarLocationID.text = @"停车位置: 广东省深圳市名优采购中心停车场";
    endCarLocationID.font = [UIFont systemFontOfSize:14];
    endCarLocationID.numberOfLines = 2;
    [middleView addSubview:endCarLocationID];

    //总费用
    UILabel * feiyong = [[UILabel alloc]initWithFrame:CGRectMake(10, 195, 50, 20)];
    feiyong.text = @"总费用";
    feiyong.font = [UIFont systemFontOfSize:14];
    [middleView addSubview:feiyong];

    //总费用
    UILabel * feiyongLabel = [[UILabel alloc]initWithFrame:CGRectMake(60, 195, 100, 20)];
    feiyongLabel.text = @"¥ 360";
    feiyongLabel.font = [UIFont systemFontOfSize:14];
    feiyongLabel.textColor = [UIColor orangeColor];
    [middleView addSubview:feiyongLabel];

    //停车熄火
    UILabel * la1Label = [[UILabel alloc]initWithFrame:CGRectMake(20, 231, 200, 20)];
    la1Label.text = @"*请停车熄火,放置好钥匙";
    la1Label.font = [UIFont systemFontOfSize:14];
    la1Label.textColor = [UIColor orangeColor];
    [middleView addSubview:la1Label];
    //下车后
    UILabel * la2Label = [[UILabel alloc]initWithFrame:CGRectMake(20, 255, 200, 20)];
    la2Label.text = @"*下车后选择 确认还车";
    la2Label.font = [UIFont systemFontOfSize:14];
    la2Label.textColor = [UIColor orangeColor];
    [middleView addSubview:la2Label];

    UIView * lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 280, needView.frame.size.width, 1)];
    lineView.backgroundColor = [UIColor grayColor];
    [middleView addSubview:lineView];

    //确认还车
    UIButton * querenBtn = [[UIButton alloc]initWithFrame:CGRectMake(140, 290, 100, 30)];
    querenBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [querenBtn setTitle:@"确认还车" forState:UIControlStateNormal];
    [querenBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [querenBtn addTarget:self action:@selector(backCarClick) forControlEvents:UIControlEventTouchUpInside];
    [middleView addSubview:querenBtn];


    //暂不还车
    UIButton * zanbuBtn = [[UIButton alloc]initWithFrame:CGRectMake(20, 290, 100, 30)];
    zanbuBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [zanbuBtn setTitle:@"暂不还车" forState:UIControlStateNormal];
    [zanbuBtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [zanbuBtn addTarget:self action:@selector(noBackClick) forControlEvents:UIControlEventTouchUpInside];
    [middleView addSubview:zanbuBtn];

}

//确认还车
- (void)backCarClick
{
    PayOrderVC * pay = [[PayOrderVC alloc]init];
    [self.navigationController pushViewController:pay animated:YES];
}

//不还车
- (void)noBackClick
{
    allView.alpha = 0;
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
{
    allView.alpha = 0;
}

@end
